
package com.gamatechno.solodestinationnew.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.gamatechno.solodestinationnew.R;

public class AdapterNavMenu extends BaseAdapter {

    private LayoutInflater inflater;
    private int[] icon;
    private String[] title;

    public AdapterNavMenu(Context context, int[] icon, String[] title) {
        // TODO Auto-generated constructor stub
        inflater = LayoutInflater.from(context);
        this.icon = icon;
        this.title = title;
    }

    @Override
    public int getCount() {
        // TODO Auto-generated method stub
        return icon.length;
    }

    @Override
    public Object getItem(int arg0) {
        // TODO Auto-generated method stub
        return icon[arg0];
    }

    @Override
    public long getItemId(int arg0) {
        // TODO Auto-generated method stub
        return 0;
    }

    static class Holder {
        ImageView thumb;
        TextView title;
    }

    @Override
    public View getView(int pos, View view, ViewGroup parent) {
        // TODO Auto-generated method stub
        Holder holder;
        if (view == null) {
            holder = new Holder();
            view = inflater.inflate(R.layout.item_nav_drawer, null);

            holder.thumb = (ImageView) view.findViewById(R.id.thumb_drawer);
            holder.title = (TextView) view.findViewById(R.id.title_drawer);

            view.setTag(holder);
        } else {
            holder = (Holder) view.getTag();
        }

        holder.thumb.setBackgroundResource(icon[pos]);
        holder.title.setText(title[pos]);

        return view;
    }
}
